//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.mybatisplus.base;

import java.util.List;

public class Pager<E> {
    private int page;
    private int pageSize;
    private long totalRecord;
    private long totalPage;
    private List<E> result;
    private Long timestamp;

    /** @deprecated */
    @Deprecated
    public static <E> Pager<E> fillPageContent(Pager page, List<E> content) {
        return page.setResult(content);
    }

    public static Pager pager(Integer page, Integer pageSize) {
        if (page == null || page < 1) {
            page = 1;
        }

        if (pageSize == null) {
            pageSize = 10;
        }

        return builder().page(page).pageSize(pageSize).build();
    }

    public static Pager pager(Integer page, Integer pageSize, Long timestamp) {
        if (page == null || page < 1) {
            page = 1;
        }

        if (pageSize == null) {
            pageSize = 10;
        }

        return builder().page(page).pageSize(pageSize).timestamp(timestamp).build();
    }

    private Pager() {
        this.page = 1;
        this.pageSize = 10;
    }

    public List<E> getResult() {
        return this.result;
    }

    public Pager setResult(List<E> result) {
        this.result = result;
        return this;
    }

    public String toString() {
        return "{\npage:" + this.page + ",\n, pageSize:" + this.pageSize + ",\n, totalRecord:" + this.totalRecord + ",\n, totalPage:" + this.totalPage + ",\n, timestamp:" + this.timestamp + ",\n, result:" + this.result + ",\n" + '}';
    }

    public void setPage(int page) {
        this.page = page < 1 ? 1 : page;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize < 0 ? 10 : pageSize;
    }

    public void setTotalRecord(long totalRecord) {
        this.totalRecord = totalRecord;
        this.setTotalPage(totalRecord % (long)this.pageSize == 0L ? totalRecord / (long)this.pageSize : totalRecord / (long)this.pageSize + 1L);
    }

    public static Pager.PagerBuilder builder() {
        return new Pager.PagerBuilder();
    }

    public int getPage() {
        return this.page;
    }

    public int getPageSize() {
        return this.pageSize;
    }

    public long getTotalRecord() {
        return this.totalRecord;
    }

    public long getTotalPage() {
        return this.totalPage;
    }

    public Long getTimestamp() {
        return this.timestamp;
    }

    public void setTotalPage(long totalPage) {
        this.totalPage = totalPage;
    }

    public void setTimestamp(Long timestamp) {
        this.timestamp = timestamp;
    }

    public boolean equals(Object o) {
        if (o == this) {
            return true;
        } else if (!(o instanceof Pager)) {
            return false;
        } else {
            Pager<?> other = (Pager)o;
            if (!other.canEqual(this)) {
                return false;
            } else if (this.getPage() != other.getPage()) {
                return false;
            } else if (this.getPageSize() != other.getPageSize()) {
                return false;
            } else if (this.getTotalRecord() != other.getTotalRecord()) {
                return false;
            } else if (this.getTotalPage() != other.getTotalPage()) {
                return false;
            } else {
                Object this$result = this.getResult();
                Object other$result = other.getResult();
                if (this$result == null) {
                    if (other$result != null) {
                        return false;
                    }
                } else if (!this$result.equals(other$result)) {
                    return false;
                }

                Object this$timestamp = this.getTimestamp();
                Object other$timestamp = other.getTimestamp();
                if (this$timestamp == null) {
                    if (other$timestamp != null) {
                        return false;
                    }
                } else if (!this$timestamp.equals(other$timestamp)) {
                    return false;
                }

                return true;
            }
        }
    }

    protected boolean canEqual(Object other) {
        return other instanceof Pager;
    }

    public int hashCode() {
        int result = 1;
         result = result * 59 + this.getPage();
        result = result * 59 + this.getPageSize();
        long $totalRecord = this.getTotalRecord();
        result = result * 59 + (int)($totalRecord >>> 32 ^ $totalRecord);
        long $totalPage = this.getTotalPage();
        result = result * 59 + (int)($totalPage >>> 32 ^ $totalPage);
        Object $result = this.getResult();
        result = result * 59 + ($result == null ? 43 : $result.hashCode());
        Object $timestamp = this.getTimestamp();
        result = result * 59 + ($timestamp == null ? 43 : $timestamp.hashCode());
        return result;
    }

    public static final class PagerBuilder<E> {
        private int page;
        private int pageSize;
        private long totalRecord;
        private long totalPage;
        private List<E> result;
        private Long timestamp;

        private PagerBuilder() {
        }

        public Pager.PagerBuilder page(int page) {
            this.page = page;
            return this;
        }

        public Pager.PagerBuilder pageSize(int pageSize) {
            this.pageSize = pageSize;
            return this;
        }

        public Pager.PagerBuilder totalRecord(long totalRecord) {
            this.totalRecord = totalRecord;
            return this;
        }

        public Pager.PagerBuilder totalPage(long totalPage) {
            this.totalPage = totalPage;
            return this;
        }

        public Pager.PagerBuilder result(List<E> result) {
            this.result = result;
            return this;
        }

        public Pager.PagerBuilder timestamp(Long timestamp) {
            this.timestamp = timestamp;
            return this;
        }

        public Pager build() {
            Pager pager = new Pager();
            pager.page = this.page;
            pager.pageSize = this.pageSize;
            pager.totalRecord = this.totalRecord;
            pager.totalPage = this.totalPage;
            pager.result = this.result;
            pager.timestamp = this.timestamp;
            return pager;
        }
    }
}
